package com.shell.customer.esign.controller;

import com.shell.bee.base.annotation.Logging;
import com.shell.bee.entity.mvc.RetMsg;
import com.shell.bee.persistence.model.PageLimit;
import com.shell.customer.base.vo.CusAcctVo;
import com.shell.customer.esign.service.EsignAuthTxService;
import com.shell.customer.util.CustomerUtil;
import com.shell.framework.utils.CommonDataUtil;
import java.math.BigDecimal;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class EsignAuthController {
	@Autowired
	private EsignAuthTxService esignAuthTxService;

	@RequestMapping
	@ResponseBody
	@Logging(module = "e����", methods = "������������")
	public RetMsg payAmountAuth(String acctNo, BigDecimal amount) {
		return this.esignAuthTxService.payAmountAuth(acctNo, amount);
	}

	@RequestMapping
	@ResponseBody
	@Logging(module = "e����", methods = "������������")
	public RetMsg payAmountAuthForAddCus(String acctNo, BigDecimal amount) {
		return this.esignAuthTxService.payAmountAuthForAddCus(acctNo, amount);
	}

	@RequestMapping
	@ResponseBody
	@Logging(module = "e����", methods = "��������������������������")
	public RetMsg toPayForAddCus(String acctNo) throws Exception {
		return this.esignAuthTxService.toPayForAddCus(acctNo);
	}

	@RequestMapping
	@ResponseBody
	@Logging(module = "e����", methods = "������������������")
	public RetMsg personBankAuth(String cardNo, String name, String mobile, String idno) {
		return this.esignAuthTxService.personBankAuth(cardNo, name, mobile, idno);
	}

	@RequestMapping
	@ResponseBody
	@Logging(module = "e����", methods = "��������������")
	public RetMsg personCodeValid(String code) {
		String custId = CommonDataUtil.getUserId();
		return this.esignAuthTxService.personCodeValid(custId, code);
	}

	@RequestMapping({ "/esign-auth/pay-notify" })
	@ResponseBody
	@Logging(module = "e����", methods = "������������")
	public void payNotify(String esign_return) {
		this.esignAuthTxService.payNotify(esign_return);
	}

	@RequestMapping
	@ResponseBody
	@Logging(module = "e����", methods = "��������")
	public RetMsg payAuth(String acctNo) {
		String custId = CommonDataUtil.getCurEntId();
		try {
			return this.esignAuthTxService.reAuth(custId, acctNo);
		} catch (Exception e) {
			e.printStackTrace();
			return new RetMsg("error", true, "��������������" + e.getMessage());
		}
	}

	@RequestMapping
	@ResponseBody
	@Logging(module = "e����", methods = "����������������������")
	public List<CusAcctVo> selectEsignAcctAuthList(PageLimit limit) {
		String custId = CommonDataUtil.getCurEntId();
		return this.esignAuthTxService.selectEsignAcctAuthList(limit, custId);
	}

	@RequestMapping
	@ResponseBody
	@Logging(module = "e����", methods = "����e��������")
	public boolean isEsignOn() {
		return CustomerUtil.onEsign();
	}
}
